package com.wf.demo.sys.controller;

import com.wf.demo.info.util.Page4Navigator;
import com.wf.demo.info.util.Result;
import com.wf.demo.sys.annotation.SysLog;
import com.wf.demo.sys.pojo.Role;
import com.wf.demo.sys.pojo.SysLogEntity;
import com.wf.demo.sys.service.SysLogService;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: wf
 * @Date: 2020/6/21 16:10
 * @Description:
 */

@RestController
public class SysLogController {
    @Autowired
    SysLogService sysLogService;


    @GetMapping("/sysLogs")
    @RequiresPermissions("sys:log")
    public Page4Navigator<SysLogEntity> list( @RequestParam(value = "start",defaultValue = "0")int start,
                                             @RequestParam(value = "size",defaultValue = "10")int size) throws Exception{
        start = start<0? 0:start;
        Page4Navigator<SysLogEntity> page = sysLogService.list(start,size,5);
        return page;
    }

    @SysLog("删除操作日志")
    @DeleteMapping("/sysLogs/{id}")
    @RequiresPermissions("sys:log")
    public Object  delete(@PathVariable("id")long id ){
        sysLogService.delete(id);
        return  Result.error(200,"删除成功");
    }
}
